#define _CRT_SECURE_NO_WANINGS 1
#pragma warning(disable: 4996)

class Solution {
public:
    int insertBits(int N, int M, int i, int j) {
        for (int k = i; k <= j; k++)
        {
            N &= ~(1 << k);
        }
        return N + (M << i);
    }
};